import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class SwingThing extends JFrame{
	
	JPanel panel;

	public SwingThing() {
		panel = new JPanel();
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		panel.setVisible(true);
		panel.setSize(500, 400);
		this.add(panel);
		JButton button = new JButton("Hey");
		panel.add(button);
		button.addActionListener(new ButtonListener());
		
	}
	
	private class ButtonListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			panel.add(new JLabel("What's up?"));
			JButton respond = new JButton("Nothing Much");
			panel.add(respond);
			respond.addActionListener(new RespondListener());
			panel.revalidate();
			panel.repaint();
		}	
	}
	
	private class RespondListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			panel.add(new JLabel("That's Cool"));
			panel.revalidate();
			panel.repaint();
		}
	}
}
